<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Magnifying Glass Effect</title>
    <style>
        .container {
            position: relative;
            width: 400px;
            height: 400px;
            overflow: hidden;
        }

        .image {
            width: 100%;
            height: 100%;
        }

        .magnifier {
            position: absolute;
            width: 100px;
            height: 100px;
            /* opacity: 0.5; */
            overflow: hidden;
            cursor: none;
            display: none;
            z-index: 99;
        }

        .magnifier img {
            position: absolute;
            width: 200%;
            height: 200%;
        }
    </style>
</head>

<body>
    <div class="container" id="magnifier-container">
        <img src="./img/GitHub头像.jpg" alt="Image" class="image">
        <div class="magnifier"></div>
    </div>
    <div class="magnifier" id="magnifier">
        <img src="./img/GitHub头像.jpg" alt="Magnified Image" class="magnified-image">
    </div>

    <script>

        // 配置参数
        const CONFIG = {
            zoomLevel: 2,
            lensSize: 150,
            transition: 0.1,
        }

        const container = document.getElementById('magnifier-container');
        const magnifier = document.getElementById('magnifier');
        const magnifiedImage = magnifier.querySelector('img');
        const containerRect = container.getBoundingClientRect();

        container.addEventListener('mousemove', function (e) {
            magnifier.style.display = 'block';
            magnifier.style.left = e.clientX - magnifier.offsetWidth / 2 + 'px';
            magnifier.style.top = e.clientY - magnifier.offsetHeight / 2 + 'px';

        })
        container.addEventListener('mouseout', function (e) {
            magnifier.style.display = 'none';
        })
    </script>
</body>

</html>